const { model } = require('mongoose')
// 引入Room集合
const { Room } = require('../modle/lsh_Room')
const { MD5 } = require('../modle/lsh_MD5')

// 登录 --- 与数据库比较
function enter(req, res) {
  console.log('我想看的是' + req.body.text_word);
  queryAllRoom({ phone: req.body.text_word, password: MD5(req.body.password) }, function (data) {
    console.log(data)
    if (data.length == 1) {
      res.send('success')
    } else {
      res.send('fail')
    }
  })
}
function queryAllRoom(value, callback) {
  Room.find(value, function (err, data) {
    if (err) {
      console.log(err);
    }
    callback(data);
  })
}

module.exports = { enter }